<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('newcrumbs.crumbsEle')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('myAuditList.no1')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('myAuditList.no2')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    
    <!-- -------------搜索查询栏------------------------ -->
    <search :searchData="searchData" 
        @search="search"  
        :searchRight="true"
        :outputRight="false">
    </search>

    <!-- <div class="list_operation" v-if="$store.state.common.permiss.myauditfirlist.includes('claim')&&tableData.length>0">
        <el-button type="primary" @click="claim">{{$t('myAuditList.no4')}}</el-button>
    </div> -->

    <!-- -------------表单显示栏------------------------ -->
    <div class="table" v-if="true">
      <template>
        <el-table :data="tableData" stripe size="small"  v-loading="loadFlag">
          <el-table-column align="center" prop="id" :label="$t('public.orderId')">
          </el-table-column>
          <el-table-column align="center" prop="userId" :label="$t('public.userId')">
          </el-table-column>
          <el-table-column align="center" prop="userName" :label="$t('public.name')">
          </el-table-column>
          <el-table-column align="center" prop="userPhone" :label="$t('public.userTel')">
          </el-table-column>
          <el-table-column align="center" prop="loanAmount" :label="$t('public.no30')">
            <template slot-scope="scope">
              <span v-if="scope.row.loanAmount">{{$store.state.common.id_currency}}{{$store.getters.moneySplit(scope.row.loanAmount)}}{{$store.state.common.vi_currency}}</span>
              <span v-else>{{$store.state.common.nullData}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="productPeriod" :label="$t('public.no31')+'('+$t('public.no26')+')'">
          </el-table-column>
          <el-table-column align="center" prop="createTime" :label="$t('public.CreateDate')" width="86">
          </el-table-column>
          <el-table-column align="center" prop="status" :label="$t('public.orderStatus')">
            <template slot-scope="scope">
              <span>{{$t($store.getters.rejectStatus(scope.row.status))}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('new.no9')" width="86">
             <template slot-scope="scope">
               <span>{{scope.row.orderExtra?scope.row.orderExtra.firstApproveTime:'-'}}</span>
             </template>
          </el-table-column>
          <el-table-column align="center"  :label="$t('new.no13')" width="86">
              <template slot-scope="scope">
                <span>{{scope.row.orderExtra?scope.row.orderExtra.firstApproveAllotTime:'-'}}</span>
                </template>
          </el-table-column>
          <el-table-column align="center" prop="trackStatus" :label="$t('new.no8')">
            <template slot-scope="scope">
              <span >{{scope.row.orderExtra?$t($store.getters.follow_status(scope.row.orderExtra.trackStatus)):'-'}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="orderExtra.approveName" :label="$t('public.no32')">
          </el-table-column>
          <el-table-column fixed="right" align="center" prop="operation" :label="$t('public.operation')" min-width="160">
            <template slot-scope="scope">
              <span class="table_opr" v-if="$store.state.common.permiss.myauditfirlist.includes('save')&&scope.row.status==20"
                @click="detail(scope.row.userId, scope.row.id, -1)">
                {{$t('myAuditList.no5')}}
              </span>
              <span class="table_opr" v-else-if="$store.state.common.permiss.myauditfirlist.includes('view')"
                @click="detail(scope.row.userId, scope.row.id, 1)">
                {{$t('public.no29')}}
              </span>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>

    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>

    <!-- ------------------ 点击转派弹窗结束 -------------------- -->

    <div class="foot"></div>

  </div>
</template>
<script>
export default {
  name: 'peopleFirstAudit',
  data () {
      const searchData=[
      {
        type: 'input',
        label: 'public.orderId',
        attr: 'orderId',
        value: ''
      },
      {
        type: 'input',
        label: 'public.userId',
        attr: 'userId',
        value: ''
      },
      {
        type: 'input',
        label: 'public.name',
        attr: 'userName',
        value: ''
      },
      {
        type: 'input',
        label: 'public.userPhone',
        attr: 'userPhone',
        value: ''
      },{
        type: 'select',
        attr: 'status',
        label: 'public.orderStatus',
        option: this.$store.state.options.peopleAuditOneStatus_options, // 订单状态下拉选框信息
        langFlag: true,
        value: ''
      },{
        type: 'select',
        attr: 'trackStatus',
        label: 'new.no8',
        option: this.$store.state.options.follow_option,
        langFlag: true,
        value: ''
      },{
        type: 'rangePicker',
        label: 'public.CreateDate',
        attr: 'searchTime1',
        value: [],
      },{
        type: 'rangePicker',
        label: 'new.no9',
        attr: 'searchTime2',
        value: [],
      },
      {
        type: 'rangePicker',
        label: 'new.no13',
        attr: 'searchTime3',
        value: [],
      }
    ]
    return {
      flag: true,
      loadFlag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      searchData:searchData,
      formInline: {// 用户查询信息数据对应字段
        orderId: '',
        userId: '',
        userName: '',
        userPhone: '',
        status: '',
        trackStatus:'',
        applyTimeBegin:'',
        applyTimeEnd:'',
        approveTimeBegin:'',
        approveTimeEnd:'',
        approveAllotTimeBegin:'',
        approveAllotTimeEnd:''
      },
      tableData: [], // 用户信息数据模拟
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    search(search) { // 搜索
        this.formInline=search;
        this.formInline.applyTimeBegin=search.searchTime1?search.searchTime1[0]:'';
        this.formInline.applyTimeEnd=search.searchTime1?search.searchTime1[1]:'';
        this.formInline.approveTimeBegin=search.searchTime2?search.searchTime2[0]:'';
        this.formInline.approveTimeEnd=search.searchTime2?search.searchTime2[1]:'';
        this.formInline.approveAllotTimeBegin=search.searchTime3?search.searchTime3[0]:'';
        this.formInline.approveAllotTimeEnd=search.searchTime3?search.searchTime3[1]:'';
        if (this.flag) {
          this.flag = false;
          this.pagination.current = 1;
          this.getTableData();
        }
    },
    detail (userId, orderId,isView) { // 点击查看详情
        this.$router.push({path: '/myauditfirdetail', query: {userId, orderId,isView}});   
    },
    getTableData () { // 获取初审列表数据
      this.loadFlag = true;
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          ...this.formInline,
        }       
      }
      this.$axios.post(this.$action.myaudit_firstList, option).then(res => {
        this.flag = true;
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.pagination.total = res.data.total;
        }else{
          this.$globalMsg.error(res.message)
        }
        this.loadFlag = false;
      })
    },
    claim () { // 初审订单认领功能
      if (this.flag) {
        this.flag = false
        let option = {
          param: {
            adminId: sessionStorage.getItem('sessionid'),
		        approveStage: 1
          }
        }
        this.$axios.post(this.$action.myaudit_claim, option).then(res => {
          this.flag = true;
          if (res.code == 200) {
            this.$globalMsg.success(res.message);
          }else{
            this.$globalMsg.error(res.message);
          }
        })
      }
    }
  },
  mounted () {
    this.getTableData();
  }
}
</script>
<style scoped lang="scss">

</style>
